<?php
/**
 * 注：此模板为自动生成模板，需要根据实际情况调整修改
 * 此模板对 无主键/单一主键 表的支持较好，联合主键表在下一版本开发
 */
namespace Data;

use Utils\MyException;

class Tree_mng_page_mst {

    //数组
    private $array;


    public function __construct ($array){

        $this->array = $array;

        self::setDefault();

    }

    public function getArray() {
        return $this->array;
    }

    public function updateWithArray($array) {
        foreach($array as $key=>$value)
        {
            if(array_key_exists($key,$this->array))
            {
                $this->array = array_merge($this->array,array($key=>$value));
            }
        }
    }



    private function setDefault(){

        if(count($this->array)==0){
            self::setPAGE_ID("null");
            self::setPAGE_NAME("");
            self::setGROUP_ID("0");
            self::setDISPLAY_ORDER("0");
            self::setURL("");
            self::setSTATE("0");
            self::setCREATED_ON("");
            self::setCREATED_BY("0");
            self::setUPDATED_ON("");
            self::setUPDATED_BY("0");

        }
    }






    public function setPAGE_ID($value) {
        $this->array = array_merge ($this->array,array(
            'PAGE_ID' => $value));
    }
    public function getPAGE_ID(){

        return $this->array ['PAGE_ID'];
    }


    public function setPAGE_NAME($value) {
        $this->array = array_merge ($this->array,array(
            'PAGE_NAME' => $value));
    }
    public function getPAGE_NAME(){

        return $this->array ['PAGE_NAME'];
    }


    public function setGROUP_ID($value) {
        $this->array = array_merge ($this->array,array(
            'GROUP_ID' => $value));
    }
    public function getGROUP_ID(){

        return $this->array ['GROUP_ID'];
    }


    public function setDISPLAY_ORDER($value) {
        $this->array = array_merge ($this->array,array(
            'DISPLAY_ORDER' => $value));
    }
    public function getDISPLAY_ORDER(){

        return $this->array ['DISPLAY_ORDER'];
    }


    public function setURL($value) {
        $this->array = array_merge ($this->array,array(
            'URL' => $value));
    }
    public function getURL(){

        return $this->array ['URL'];
    }


    public function setSTATE($value) {
        $this->array = array_merge ($this->array,array(
            'STATE' => $value));
    }
    public function getSTATE(){

        return $this->array ['STATE'];
    }


    public function setCREATED_ON($value) {
        $this->array = array_merge ($this->array,array(
            'CREATED_ON' => $value));
    }
    public function getCREATED_ON(){

        return $this->array ['CREATED_ON'];
    }


    public function setCREATED_BY($value) {
        $this->array = array_merge ($this->array,array(
            'CREATED_BY' => $value));
    }
    public function getCREATED_BY(){

        return $this->array ['CREATED_BY'];
    }


    public function setUPDATED_ON($value) {
        $this->array = array_merge ($this->array,array(
            'UPDATED_ON' => $value));
    }
    public function getUPDATED_ON(){

        return $this->array ['UPDATED_ON'];
    }


    public function setUPDATED_BY($value) {
        $this->array = array_merge ($this->array,array(
            'UPDATED_BY' => $value));
    }
    public function getUPDATED_BY(){

        return $this->array ['UPDATED_BY'];
    }


    public function toInsertCSV() {
        $str="";

        // PAGE_ID
        $str .= self::getPAGE_ID().",";
        // PAGE_NAME
        $str .= "'". self::getPAGE_NAME()."',";
        // GROUP_ID
        $str .= "'". self::getGROUP_ID()."',";
        // DISPLAY_ORDER
        $str .= "'". self::getDISPLAY_ORDER()."',";
        // URL
        $str .= "'". self::getURL()."',";
        // STATE
        $str .= "'". self::getSTATE()."',";
        // CREATED_ON
        $str .= "now()" . ",";

        // CREATED_BY
        $str .= "'". self::getCREATED_BY()."',";
        // UPDATED_ON
        $str .= "now()" . ",";

        // UPDATED_BY
        $str .= "'". self::getUPDATED_BY()."'";
        return $str;
    }



    public function toUpdateSet() {
        $str="";

        // PAGE_NAME
        $str.= '`PAGE_NAME` = "' . self::getPAGE_NAME() . '",';

        // GROUP_ID
        $str.= '`GROUP_ID` = "' . self::getGROUP_ID() . '",';

        // DISPLAY_ORDER
        $str.= '`DISPLAY_ORDER` = "' . self::getDISPLAY_ORDER() . '",';

        // URL
        $str.= '`URL` = "' . self::getURL() . '",';

        // STATE
        $str.= '`STATE` = "' . self::getSTATE() . '",';

        // CREATED_ON
        $str.= '`CREATED_ON` = "' . self::getCREATED_ON() . '",';

        // CREATED_BY
        $str.= '`CREATED_BY` = "' . self::getCREATED_BY() . '",';

        // UPDATED_ON
        $str .= "UPDATED_ON = now()," ;

        // UPDATED_BY
        $str.= '`UPDATED_BY` = "' . self::getUPDATED_BY(). '"';
        return $str;
    }



    public function toUpdateWhere(){
        $str = "";
        $str .= "`PAGE_ID` = '" . self::getPAGE_ID()."'";
        return $str;
    }

}


